/*******************************************************************************
 * @brief: 参数表定义
 * @Author:   aple
 * @Date: 2020-09-02 23:35:00
 * @LastEditors: aple
 * @LastEditTime: 2022-11-12 10:00:49
 * @Verision: 1.0.0.0
 ******************************************************************************/

#ifndef PARTAB_H_H_
#define PARTAB_H_H_

#ifdef _PARTAB_MODULE_
#define PAR_EXT
#else
#define PAR_EXT extern
#endif

#include "appcfg.h"
#include "mytype.h"
#include "par_jump.h"
#include "par_save.h"

#ifdef __cplusplus
extern "C"
{
#endif

#define PAR_LIST_CREAT
#include "par_def.h"
#undef PAR_LIST_CREAT

//------------------------------------------------------------------------------
//-------------------------------  opt sel   -----------------------------------
//------------------------------------------------------------------------------
#define PAR_OPT_SEL_SYS 0

	//------------------------------------------------------------------------------
	//------------------------------- system par -----------------------------------
	//------------------------------------------------------------------------------
	extern par_attr_type par_attr_tab[];
	PAR_EXT par_tab_type sys_par;

	//------------------------------------------------------------------------------
	uint16_t par_attr_get(uint16_t par_num);
	int32_t par_min_get(uint16_t par_num);
	int32_t par_max_get(uint16_t par_num);
	int32_t par_val_get(uint16_t par_num);
	int32_t par_val_set(uint16_t par_num, int32_t par_val);
	extern uint32_t par_ext_save_req;

//------------------------------------------------------------------------------
// 参数操作
#define par_pos(par) ((uu32)(&((par_tab_type *)0)->par) / 2)
#define par_set(par, val) par_val_set(par_pos(par), val)
#define par_get(par) par_val_get(par_pos(par))
#define par_tab ((u16_tt *)(&sys_par))

//------------------------------------------------------------------------------
#ifndef _PARTAB_MODULE_
	uint8_t par_check(uint16_t par_num, int32_t par_val);
	int32_t par_correct(uint16_t par_num, int32_t par_val);
	extern par_jump_list_type par_jump_list[];
#endif

	//------------------------------------------------------------------------------
	extern const par_jump_list_type par_tab_jump[];

	//------------------------------------------------------------------------------

	//------------------------------------------------------------------------------
	//------------------------------- group par ------------------------------------
	//------------------------------------------------------------------------------
	extern const par_attr_type gp_par_attr_tab[][12];

	PAR_EXT gp_par_def_type gp_par[GP_LIST_MAX + 1];

#define gp_par_pos(par) ((uu32)(&((gp_par_def_type *)0)->par) / 2)
#define gp_par_tab(gp) ((u16_tt *)(&gp_par[gp]))

	// 基本 操作
	uint8_t gp_par_check(uint16_t attr_gp, uint16_t par_num, int32_t par_val);
	int32_t gp_par_correct(uint16_t attr_gp, uint16_t par_num, int32_t par_val);
	uint16_t gp_par_attr_get(uint16_t attr_gp, uint16_t par_num);
	int32_t gp_par_min_get(uint16_t attr_gp, uint16_t par_num);
	int32_t gp_par_max_get(uint16_t attr_gp, uint16_t par_num);

	// gp_par_list 操作，内含EEP操作
	int32_t gp0_par_get(uint16_t par_num);
	int32_t gp0_par_set(uint16_t par_num, int32_t par_val);
	int32_t gp_par_get(uint16_t gp, uint16_t par_num);
	int32_t gp_par_set(uint16_t gp, uint16_t par_num, int32_t par_val);

#undef PAR_EXT

#ifdef __cplusplus
}
#endif

#endif /* PARTAB_H_H_ */
